package com.unitd.base.frame.plugin.module.model;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * 自定义的实体类的基类, 该类用于定义所有实体类的共有和通用字段,以及主键生成策略
 *
 * @author Hudan
 * @version 1.0
 * @filename MybatisBaseEntity.java
 * @copyright www.unitd.cn
 * @date 2019-01-23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString
@EqualsAndHashCode
public class MybatisBaseEntity implements Serializable, Cloneable {

    /** 自增主键ID */
    @TableId(value = "id", type = IdType.AUTO)
    protected Long id;
    /** 数据状态(0:无效; 1:有效) */
    protected String status;
    /** 是否已删除(0:否; 1:是) */
    @TableField("delete_flag")
    protected String deleteFlag;
    /** 创建时间 */
    @TableField(value = "create_time", fill = FieldFill.INSERT_UPDATE)
    protected Date createTime;
    /** 更新时间 */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    protected Date updateTime;
    /** 备注信息 */
    @TableField("remark")
    protected String remark;

    public MybatisBaseEntity(Long id) {
        this.id = id;
    }

    /**
     * 设置公共属性为空
     */
    protected void setNull() {
        setId(null);
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}